<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>绑定样式</title>
  <style>
    .active{
      color:blue;
    }
  </style>
  <script src="./js/vue2.js"></script>
</head>
<body>
  <div id="app">
    <!-- 对象绑定方式 -->
    <!-- <div @click="handleClick" :class="{active: isAct}">hello world</div> -->
    <!-- 数组绑定方式 -->
    <!-- <div @click="handleClick" :class="[active]">hello world</div> -->

    <!-- style的对象绑定 -->
    <!-- <div @click="handleClick" :style="styleObj">hello world</div> -->
    <!-- style的数组绑定 -->
    <div @click="handleClick" :style="[styleObj]">hello world</div>

  </div>
</body>
</html>
<script>
  var app = new Vue({
    el:'#app',
    data: {
      isAct: false,
      active: '',
      styleObj: {
        color: "red",
      }
    },
    methods: {
      handleClick: function(){
        // 对象绑定
        // this.isAct = !this.isAct;
        // 数组绑定
        // this.active=this.active==='active'?'':'active';

        // style
        this.styleObj.color=this.styleObj.color==='red'?'blue':'red';
      }
    }
  });
</script>